<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/module/index/_taglib.jsp" %>
<!DOCTYPE html>
<html>
	<head>
		<title>JC mms</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<jsp:include page="/_loadCssScript.jsp"></jsp:include>
		<script type="text/javascript">
			$(function(){
				
				var reload = function(){
					var uri = $("form:first").attr("action");
					var paramsObj = $("form:first").find(":input[type='text'], :hidden");
					var params = "";
					var isFirstParam = true;
					$.each(paramsObj, function(index, item){
						//alert(item.value);
						if(item.name != null && item.name != ''){
							if($.trim(item.value) != ''){
								if(isFirstParam){
									isFirstParam = false;
								}else{
									params += "&";
								}
								params += item.name + "=" + encodeURIComponent(item.value);
							}
							$(item).val($.trim(item.value));
						}
					});
					if(params != ""){
						uri += "?" + params;
					}
					window.location.href = uri;
				};
				
				$("#searchBtn").click(function(){
					reload();
				});
				
				$("#updateLocale").click(function(){
					var uri = "<%=request.getContextPath() %>/module/subscriber/updateLocale.do?id=";
					var id = $(this).parent().prevAll(":last").html();
					uri += id;
					$.get(uri, function(){
						reload();
					});
				});
				
				$(".pagination a").click(function(){
					var pageNumber = $(this).html();
					$(":input[name='pageNumber']").val(pageNumber);
					reload();
				});
				
			});
		</script>
	</head>
	<body>
		<jsp:include page="/module/index/_top_navbar.jsp"></jsp:include>
		
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span2">
					<jsp:include page="/module/index/_menu.jsp"></jsp:include>
				</div>
				<div class="span10">
					<!-- 站点路径 -->
					<ul class="breadcrumb">
						<li><a href="<%=request.getContextPath() %>/">首页</a> <span class="divider">/</span></li>
						<li><a href="javascript:void(0);">系统管理</a> <span class="divider">/</span></li>
						<li class="active">订阅用户</li>
					</ul>
					
					<form action="<%=request.getContextPath() %>/module/subscriber/list.do" method="post">
						<div class="navbar">
							<div class="navbar-inner">
								<p class="navbar-text pull-left">手机号：</p>
								<div class="navbar-form">
									<input type="text" name="mobileNumber" value="${subscriber.mobileNumber }"/>
									<button id="searchBtn" type="button" class="btn">查询</button>
								</div>
							</div>
						</div>
						
						<table class="table table-condensed table-hover table-striped">
							<thead>
								<tr>
									<th>ID</th>
									<th>手机号码</th>
									<th>归属地</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
							<c:if test="${rows != null }">
								<c:forEach items="${rows}"  var="row">
									<tr>
										<td>${row.id }</td>
										<td>${row.mobileNumber }</td>
										<td>${row.locale }</td>
										<td>
											&nbsp;<a href="javascript:void(0);" onclick="location.href=('<%=request.getContextPath()%>/module/subscriber/detail.do?id=${row.id }&fromUrl=' + encodeURIComponent(location.href));">详细</a>&nbsp;
											&nbsp;<a href="javascript:void(0);" id="updateLocale" >归属地</a>&nbsp;
										</td>
									</tr>
								</c:forEach>
							</c:if>
							</tbody>
						</table>
						
						<div class="pagination">
							<input type="hidden" name="pageNumber" value="${pageBean.currentPage }"/>
							<ul>
								<c:if test="${pageBean.currentPage - 2 >= 2 && pageBean.currentPage - 2 > 0 }">
									<li class="active"><a href="javascript:void(0);">1</a></li>
								</c:if>
								${pageBean.currentPage - 2 > 2 ? "<li>...</li>" : ""}
								<c:forEach begin="${pageBean.currentPage - 2 >= 1 ? pageBean.currentPage - 2 : 1}" end="${pageBean.currentPage + 4 >= pageBean.totalPages ? pageBean.totalPages : pageBean.currentPage + 4}" var="value">
									<li ${pageBean.currentPage == value ? "class='active'" : ""}><a href="javascript:void(0);">${value }</a></li>
								</c:forEach>
								${pageBean.currentPage + 5 < pageBean.totalPages ? "<li>...</li>" : ""}
								<c:if test="${pageBean.currentPage + 4 < pageBean.totalPages}">
									<li class="active"><a href="javascript:void(0);">${pageBean.totalPages }</a></li>
								</c:if>
							</ul>
						</div>
					</form>
				</div>
		    </div>
	    </div>
	</body>
</html>